package com.xiaoke.java;

import java.nio.ByteBuffer;
import java.util.Scanner;

/**
 * IO                 NIO(New IO/ Non-Blocking IO
 * byte[] / char[]    Buffer
 *Stream              channel
 *
 *
 *
 *查看直接内存的占用与释放
 * @author xiao-ke
 * @createTime 2022年02月24日 18:38:00
 */
public class BufferTest {

    private static final int BUFFER = 1024*1024*1024;//1GB

    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BUFFER);
        System.out.println("直接内存分配完毕，请求指示！！");

        Scanner scanner = new Scanner(System.in);
        scanner.next();

        System.out.println("直接内存开始释放！");
        byteBuffer = null;
        System.gc();
        scanner.next();
    }

}
